'use strict'
window.globalMap = {
    map: {},
    instance: {},
    loading: false,
    type: null,
    markers: [],
    polylines: [],
    infoWindows: []
};
import { _xhb_map_waitForParameterReady } from './utils/util.js'
import _AMapComponent from './src/init/AMap/index.js';
import _BMapComponent from './src/init/BMap/index.js';
import _EGisComponent from './src/init/egis/index.js';
class MapCraft {
    constructor(opt) {
        switch (opt.type) {
            case 'AMap':
                this.map = new _AMapComponent(opt);
                this.map.initMap();
                break;
            case 'BMap':
                this.map = new _BMapComponent(opt);
                this.map.initMap();
                break;
            case 'egis':
                this.map = new _EGisComponent(opt);
                this.map.initMap();
                break;
            default:
                throw new Error("请输入正确的地图类型【AMap,BMap,egis】.");
        }
        this.Marker = new Marker(this.map);
        this.Polyline = new Polyline(this.map);
        this.InfoWindow = new InfoWindow(this.map)
    }
}
class Polyline {
    constructor(map) {
        this.map = map;
    }
    addPolyline(id, options, markerEvent) {
        _xhb_map_waitForParameterReady(() => {
            this.map.addPolyline(id, options, markerEvent);
        })
    }

    delPolyline(id) {
        _xhb_map_waitForParameterReady(() => {
            this.map.delPolyline(id);
        })
    }
}

class Marker {
    constructor(map) {
        this.map = map;
    }
    addMarker(id, options, markerEvent) {
        _xhb_map_waitForParameterReady(() => {
            this.map.addMarker(id, options, markerEvent);
        })
    }

    delMarker(id) {
        _xhb_map_waitForParameterReady(() => {
            this.map.delMarker(id);
        })
    }
}

class InfoWindow {
    constructor(map) {
        this.map = map;
    }

    addInfoWindow(id, opt, markerEvent) {
        _xhb_map_waitForParameterReady(() => {
            this.map.addInfoWindow(id, opt, markerEvent);
        })
    }

    delInfoWindow(id) {
        _xhb_map_waitForParameterReady(() => {
            this.map.delInfoWindow(id);
        })
    }
}
export default MapCraft